<?php
// +------------------------------------------------
// | Version:Toper 1.1
// +------------------------------------------------
// | Author:mingtingling 717547858@qq.com
// +------------------------------------------------
// | Copyright www.qingyueit.com
// +------------------------------------------------

/**
 +--------------------------------------------------
 * Toper 缓存的抽象基类
 +--------------------------------------------------
 * @category Toper
 * @package Core
 * @subpackage Cache
 * @author mingtingling
 * @version 1.1
 +--------------------------------------------------
 */

abstract class Tp_CacheAbstract extends Tp {
	
	protected $_cache = null; //缓存连接句柄

	/**
	+---------------------------------------------------------------
	* 判定是否已经连接
	+---------------------------------------------------------------
	* @access public
	* @param void
	* @return bool
	+---------------------------------------------------------------
	*/
	public function isConnected() {
		return (null === $this->_cache) ? false : true;
	}
	
	/**
	+---------------------------------------------------------------
	* 连接到缓存
	+---------------------------------------------------------------
	* @access public
	* @param void
	* @return void
	+---------------------------------------------------------------
	*/
	abstract public function connect();
	
	
	/**
	+---------------------------------------------------------------
	* 得到某一个缓存变量的值
	+---------------------------------------------------------------
	* @access public
	* @param string $name
	* @return mixed
	+---------------------------------------------------------------
	*/
	abstract public function get($name);
	
	/**
	+---------------------------------------------------------------
	* 设置某一个缓存变量的值
	+---------------------------------------------------------------
	* @access public
	* @param string $name
	* @param mixed $val
	* @param int $expire 过期时间
	* @return bool
	+---------------------------------------------------------------
	*/
	abstract public function set($name,$val,$expire = null);
	
	/**
	+---------------------------------------------------------------
	* 是否存在某一个缓存变量的值
	+---------------------------------------------------------------
	* @access public
	* @param string $name
	* @return bool
	+---------------------------------------------------------------
	*/
	abstract public function have($name);
	
	/**
	+---------------------------------------------------------------
	* 移除某一个缓存变量的值
	+---------------------------------------------------------------
	* @access public
	* @param string $name
	* @return void
	+---------------------------------------------------------------
	*/
	abstract public function remove($name);
	
	/**
	+---------------------------------------------------------------
	* 清除所有缓存
	+---------------------------------------------------------------
	* @access public
	* @param void
	* @return void
	+---------------------------------------------------------------
	*/
	abstract public function clear();
}